#ifndef TIMER_H
#define TIMER_H
#include <time.h>
#include <string>
#include <iostream>

using namespace std;
class timer
{
    public:
        timer() {}
        string getStartTime() {
            time(&m_time);
            t_tm = localtime(&m_time);
            strstream TimeToStr;
            string s_year, s_month, s_day;
            TimeToStr.clear();
            TimeToStr << (t_tm->tm_year + 1900);
            TimeToStr >> s_year;
            TimeToStr.clear();
            TimeToStr << (t_tm->tm_mon + 1);
            TimeToStr >> s_month;
            TimeToStr.clear();
            TimeToStr << t_tm->tm_mday;
            TimeToStr >> s_day;
            string s_time = s_year + '/' + s_month + '/' + s_day;
            return s_time;
        }

        string getEndTime(int num) {
            time(&m_time);
            t_tm = localtime(&m_time);
            strstream TimeToStr;
            string e_year, e_month, e_day;
            TimeToStr.clear();
            if (num != -1) {
                TimeToStr << (t_tm->tm_year + 1903);
            } else {
                TimeToStr << (t_tm->tm_year + 1901);
            }
            TimeToStr >> e_year;
            TimeToStr.clear();
            TimeToStr << (t_tm->tm_mon + 1);
            TimeToStr >> e_month;
            TimeToStr.clear();
            TimeToStr << t_tm->tm_mday;
            TimeToStr >> e_day;
            string e_time = e_year + '/' + e_month + '/' + e_day;
            return e_time;
        }
        virtual ~timer() {}
        protected:
        private:
            time_t m_time;
            tm *t_tm;
};

#endif // TIMER_H
